package de.grosjohann.android.feuerwehr.service;

import android.app.IntentService;
import android.content.Context;
import android.content.Intent;
import android.util.Log;
import de.grosjohann.android.feuerwehr.IUpdateUIListener;
import de.grosjohann.android.feuerwehr.util.FileUtil;

public class WeatherDisplayService
  extends IntentService {

  public static IUpdateUIListener updateUIListener;

  private static final String NAME = "WeatherDisplayService";

  public WeatherDisplayService() {
    super(NAME);
  }

  @Override
  public void onCreate() {
    super.onCreate();

    Log.d(NAME, "create");
  }

  @Override
  protected void onHandleIntent(Intent newIntent) {

    Log.d(NAME, "handle");

    Context context = getApplicationContext();

    String json = FileUtil.readFile(context, WeatherNotificationService.WEATHER_DATA);

    if (updateUIListener != null) {
      updateUIListener.updateUI(json);
    }
  }
}
